home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / security / Key.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  3.8 KB  |  112 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)Key.java    1.42 98/06/29
  3.  *
  4.  * Copyright 1996-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.security;
  16.  
  17. /**
  18.  * The Key interface is the top-level interface for all keys. It
  19.  * defines the functionality shared by all key objects. All keys
  20.  * have three characteristics:
  21.  *
  22.  * <UL>
  23.  *
  24.  * <LI>An Algorithm
  25.  *
  26.  * <P>This is the key algorithm for that key. The key algorithm is usually
  27.  * an encryption or asymmetric operation algorithm (such as DSA or
  28.  * RSA), which will work with those algorithms and with related
  29.  * algorithms (such as MD5 with RSA, SHA-1 with RSA, Raw DSA, etc.)
  30.  * The name of the algorithm of a key is obtained using the
  31.  * {@link getAlgorithm() getAlgorithm} method.<P>
  32.  *
  33.  * <LI>An Encoded Form
  34.  *
  35.  * <P>This is an external encoded form for the key used when a standard
  36.  * representation of the key is needed outside the Java Virtual Machine,
  37.  * as when transmitting the key to some other party. The key
  38.  * is encoded according to a standard format (such as X.509 or PKCS#8), and
  39.  * is returned using the {@link getEncoded() getEncoded} method.<P>
  40.  *
  41.  * <LI>A Format
  42.  *
  43.  * <P>This is the name of the format of the encoded key. It is returned
  44.  * by the {@link getFormat() getFormat} method.<P>
  45.  *
  46.  * </UL>
  47.  *
  48.  * Keys are generally obtained through key generators, certificates,
  49.  * or various Identity classes used to manage keys.
  50.  * Keys may also be obtained from key specifications (transparent
  51.  * representations of the underlying key material) through the use of a key
  52.  * factory (see {@link KeyFactory}).
  53.  *
  54.  * @see PublicKey
  55.  * @see PrivateKey
  56.  * @see KeyPair
  57.  * @see KeyPairGenerator
  58.  * @see KeyFactory
  59.  * @see java.security.spec.KeySpec
  60.  * @see Identity
  61.  * @see Signer
  62.  *
  63.  * @version 1.42 99/03/26
  64.  * @author Benjamin Renaud
  65.  */
  66.  
  67. public interface Key extends java.io.Serializable {
  68.  
  69.     // Declare serialVersionUID to be compatible with JDK1.1
  70.     static final long serialVersionUID = 6603384152749567654L;
  71.  
  72.     /**
  73.      * Returns the standard algorithm name for this key. For
  74.      * example, "DSA" would indicate that this key is a DSA key.
  75.      * See Appendix A in the <a href=
  76.      * "../../../guide/security/CryptoSpec.html#AppA">
  77.      * Java Cryptography Architecture API Specification & Reference </a>
  78.      * for information about standard algorithm names.
  79.      *
  80.      * @return the name of the algorithm associated with this key.
  81.      */
  82.     public String getAlgorithm();
  83.  
  84.     /**
  85.      * Returns the name of the primary encoding format of this key,
  86.      * or null if this key does not support encoding.
  87.      * The primary encoding format is
  88.      * named in terms of the appropriate ASN.1 data format, if an
  89.      * ASN.1 specification for this key exists.
  90.      * For example, the name of the ASN.1 data format for public
  91.      * keys is <I>SubjectPublicKeyInfo</I>, as
  92.      * defined by the X.509 standard; in this case, the returned format is
  93.      * <code>"X.509"</code>. Similarly,
  94.      * the name of the ASN.1 data format for private keys is
  95.      * <I>PrivateKeyInfo</I>,
  96.      * as defined by the PKCS #8 standard; in this case, the returned format is
  97.      * <code>"PKCS#8"</code>.
  98.      *
  99.      * @return the primary encoding format of the key.
  100.      */
  101.     public String getFormat();
  102.  
  103.     /**
  104.      * Returns the key in its primary encoding format, or null
  105.      * if this key does not support encoding.
  106.      *
  107.      * @return the encoded key, or null if the key does not support
  108.      * encoding.
  109.      */
  110.     public byte[] getEncoded();
  111. }
  112.